<template>
  <div class="p-4" v-enter-helper="getList">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <div class="flex mt-3">
          <el-input
            v-model="listQuery.user_id"
            class="ml-4"
            style="width: 17%"
            placeholder="请输入用户Id"
            clearable
          ></el-input>
          <el-input
            v-model="listQuery.room_id"
            class="ml-4"
            style="width: 17%"
            placeholder="请输入房间Id"
            clearable
          ></el-input>

          <div class="ml-4 flex items-center" style="width: 17%">
            <el-button type="primary" icon="el-icon-search" @click="getList"
              >搜索</el-button
            >
          </div>
        </div>
      </div>

      <el-table :data="tableData" border>
        <el-table-column prop="id" label="序号" width="150px"></el-table-column>
        <el-table-column prop="user_data" label="发起用户">
          <template slot-scope="scope">
            <div>{{ scope.row.user_data.nickname }}</div>
          </template>
        </el-table-column>
        <el-table-column prop="user_data" label="发起用户id">
          <template slot-scope="scope">
            <div>{{ scope.row.user_data.user_code }}</div>
          </template>
        </el-table-column>
        <el-table-column prop="name" label="活动类型">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.join_type === 1">答题</el-tag>
            <el-tag v-if="scope.row.join_type === 2">送礼</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="created_at" label="活动时间"></el-table-column>
        <el-table-column label="奖品内容">
          <template slot-scope="scope">
            <div>{{ scope.row.gift ? scope.row.gift.name : "" }}</div>
          </template>
        </el-table-column>
        <el-table-column prop="room_id" label="房间id">
          <template slot-scope="scope">
            <div v-if="scope.row.user_room">
              {{ scope.row.user_room.room_id }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="room_name" label="房间名称">
          <template slot-scope="scope">
            <div v-if="scope.row.user_room">
              {{ scope.row.user_room.room_name }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="winner_num" label="奖品个数"></el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button
              type="primary"
              plain
              size="mini"
              icon="el-icon-menu"
              @click="deBounceWrap(handleDetails, scope.row)"
              >查看中奖详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <cus-pagination
        :total="total"
        :page.sync="listQuery.page"
        :limit.sync="listQuery.page_size"
        @pagination="getList"
      />
    </el-card>
  </div>
</template>

<script>
import { getScreenLog } from "@/api/publicScreen/publicScreen";
export default {
  data() {
    return {
      tableData: [],
      listQuery: {
        user_id: null,
        room_id: null,
        page: 1,
        page_size: 10
      },
      total: 0,
      currentId: ""
    };
  },
  created() {
    this.getList();
  },
  methods: {
    //列表
    getList() {
      let data = this.filterObjNull(this.listQuery);
      getScreenLog(data).then(res => {
        this.tableData = res.data.list;
        this.total = res.data.total;
      });
    },
    handleDetails(row) {
      this.currentId = row.id;
      this.$router.push({
        path: "./screenRecordDetails",
        query: { activity_id: this.currentId }
      });
    }
  }
};
</script>
<style lang="scss" scoped></style>
